<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<table id="users_da"></table>
		<script type="text/javascript">
			$(function(){
				$('#users_da').datagrid({
					url:'users',
					method:"get",
					pagination:true,
					fitColumns:true,
					scrollbarSize: 0,
					fit: true,
					border:false,
					pageSize:10,
					columns:[[
						{field:'id',title:'id',width:20},
						{field:'username',title:'username',width:70},
						{field:'email',title:'email',width:145},
						{field:"state",title:"用户状态",width:55,formatter:function(value,row,index){
							if(value == 1){
								return "正常状态";
							}else{
								return "禁用状态";
							}
						}},
						{field:'role',title:'role',width:55,formatter:function(value,row,index){
							return value.roleName;
						}}
					]]
				});
			})
			function add(){
				alert("未定义");
			}
			function deleted(){
				var rows = $("#users_da").datagrid("getSelections");
				if(rows.length < 1){
					$.messager.alert("信息提示","请勾选您要删除的数据！","info");
				}else{
					$.messager.confirm("信息提示","确定要删除选中的记录吗？",function(result){
						if(result){
							var ids = [];
							$(rows).each(function(){
								ids.push(this.id);
							});
							$.ajax({
								url:"/filesharingsystem/users",
								method:"delete",
								contentType: "application/json;charset=utf-8",
								data:JSON.stringify(ids),
								success:function(data){ //"ok","error"
										user_reload();
								},
								error:function(){
									$.messager.alert("信息提示","删除失败！");
								}
							});
						}
					});
				}
			}
			function put(){
				alert("未定义");
			}
			function select(){
				alert("未定义");
			}
			function user_reload() {
				$("#users_da").datagrid("reload");
			}
		</script>
	</body>
</html>
